// pages/gatherHouse/selectWebsite/selectWebsite.js
import api from "../../../common/api"
import p from "../../../utils/platform"
import { moveHouseLog } from "../../../common/log"


Page({

  /**
   * 页面的初始数据
   */
  data: {
    model: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    api.queryPmReferenceDetailInfoByRefCode({refCode: "PickOutHouseList"}, (res) => {
      try {
        const list = res.data.content.map((item) => {
            if (item) {
              let value = JSON.parse(item.refDetailValue)
              item = {...item, ...value}
      
              return item
            }
        }) 
       this.setData({
         model: list
       })
        
      } catch (error) {
        
      }
    })

    moveHouseLog({logType: "0"})
  },

  handleGo(e) {
    const index = e.currentTarget.dataset.index
    const info = this.data.model[index]
    p.navigateTo({url: `/pages/gatherHouse/addHouse/addHouse?refDetailCode=${info.refDetailCode}&delegationType=${info.delegationType}`})
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
})